package com.ciis.testing;

import java.io.UnsupportedEncodingException;

/**
 * Created with IntelliJ IDEA.
 * User: zhangdajun
 * Date: 14-6-2
 * Time: 上午10:38
 * To change this template use File | Settings | File Templates.
 */
public class ControllerTest{
    /*private static HandlerMapping handlerMapping;
    private static HandlerAdapter handlerAdapter;

    *//**
     * 读取spring3 MVC配置文件
     *
     * @throws UnsupportedEncodingException
     *//*
    @BeforeClass
    public static void setUp() throws UnsupportedEncodingException {
        if (handlerMapping == null) {
            String[] configs = {"file:D:/project/workspace/oschina/CIIS/web/WEB-INF/conf/spring/spring-context-sqlMap.xml",
                    "file:D:/project/workspace/oschina/CIIS/web/WEB-INF/conf/spring/spring-servlet.xml"};
            XmlWebApplicationContext context = new XmlWebApplicationContext();
            context.setConfigLocations(configs);
            MockServletContext msc = new MockServletContext();
            context.setServletContext(msc);
            context.refresh();
            msc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
                    context);
            handlerMapping = (HandlerMapping) context
                    .getBean(RequestMappingHandlerMapping.class);
            handlerAdapter = (HandlerAdapter) context
                    .getBean(context
                            .getBeanNamesForType(RequestMappingHandlerAdapter.class)[0]);
        }
    }

    *//**
     * 执行request对象请求的action
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     *//*
    public ModelAndView excuteAction(HttpServletRequest request,
                                     HttpServletResponse response) throws Exception {
        // 这里需要声明request的实际类型，否则会报错
        request.setAttribute(HandlerMapping.INTROSPECT_TYPE_LEVEL_MAPPING, true);
        HandlerExecutionChain chain = handlerMapping.getHandler(request);
        ModelAndView model = null;
        try {
            model = handlerAdapter
                    .handle(request, response, chain.getHandler());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return model;
    }*/

}
